//
//  SettingViewController.m
//  AppointmentForCar
//
//  Created by Herron on 16/10/3.
//  Copyright © 2016年 Herron. All rights reserved.
//

#import "SettingViewController.h"
#import "AboutUsViewController.h"
#import "AppDelegate.h"
#import "AddressViewController.h"

@interface SettingViewController ()

@end

@implementation SettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"设置";
}

- (void)viewWillAppear:(BOOL)animated {
    self.navigationController.navigationBar.translucent = NO;
    self.navigationController.navigationBar.hidden = NO;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}


- (IBAction)addressClick:(id)sender {
    AddressViewController *vc = [[AddressViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}


- (IBAction)aboutUsClick:(id)sender {
    AboutUsViewController *vc = [[AboutUsViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}



- (IBAction)logoutClick:(id)sender {
    
    UIAlertController *controller = [UIAlertController alertControllerWithTitle:@"确认退出" message:nil preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *ok = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [[UserAccountManager shareUserManager] logout];
        AppDelegate *appDelegate = kAppDelegate;
        [appDelegate setRootViewController];
    }];
    UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    }];
    [controller addAction:ok];
    [controller addAction:cancel];
    
    [self presentViewController:controller animated:YES completion:nil];    
}

@end
